package Dao;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;

import org.junit.Before;
import org.junit.Test;

import Entity.LearningResource;
import junit.framework.Assert;

public class LearningResourceDaoTest {
	LearningResource lr=new LearningResource("2018194620190617125","sqlsever","AirTicketSystem.zip","20181946","20190617",
			"D:\\eclipseJavaEE-workspace\\.metadata\\.plugins\\org.eclipse.wst.server.core\\tmp0\\wtpwebapps\\UniversityResourceSystem\\20161946/AirTicketSystem.zip",
			1,null,null,"这是数据库课程设计");
	LearningResourceDao lrd=new LearningResourceDao();
	List<LearningResource> lrlist=new ArrayList<LearningResource>();

	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void testAddLearningResource() {
		assertEquals(1,lrd.addLearningResource(lr));
	}

	@Test
	public void testDeleteLearningResourceByResourceId() {
		assertEquals(1,lrd.deleteLearningResourceByResourceId("2016194520190617102"));
	}

	@Test
	public void testShowAllLearningResourceOrderByThumbNumber() {
		lrlist=lrd.showAllLearningResourceOrderByThumbNumber();
		Assert.assertNotNull(lrlist);
	}

	@Test
	public void testQueryLearningResourceByLabel() {
		lrlist=lrd.queryLearningResourceByLabel("andriod");
		for(int i=0;i<lrlist.size();i++) {
			assertEquals("andriod",lrlist.get(i).label);
		}
	}

	@Test
	public void testQueryLearningResourceByUploaderID() {
		lrlist=lrd.queryLearningResourceByUploaderID("20161946");
		for(int i=0;i<lrlist.size();i++) {
			assertEquals("20161946",lrlist.get(i).uploaderID);
		}
	}

	@Test
	public void testQueryLearningResourceByResourceID() {
		assertEquals("2016194620190617125",lrd.queryLearningResourceByResourceID("2016194620190617125").resourceID);
	}

	@Test
	public void testUpdateThumbNumberOfLearningResource() {
		assertEquals(1,lrd.updateThumbNumberOfLearningResource("2016194620190617125"));
	}

	@Test
	public void testQueryRecordCount() {
		assertEquals(10,lrd.queryRecordCount());
	}

}
